package com.team20.map_demo.controller;

import com.team20.map_demo.domain.Region;
import com.team20.map_demo.service.RegionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.List;

@Controller
@RequestMapping("/region")
public class SearchController {
    @Autowired
    private RegionService regionService;
    @RequestMapping(value = "/search",method = RequestMethod.POST)
    public String search(String searchregion, Model model){
        List<Region> regions=regionService.searchRegionName(searchregion);
        model.addAttribute("regions",regions);
        return "district-list";
    }
}
